﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Portal.Web.Admin.Article
{
    public partial class Delete : BasePage
    {
        private readonly IArticleRepository<IArticle> _articleRepository;

        public Delete(IArticleRepository<IArticle> articleRepository)
        {
            _articleRepository = articleRepository;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            var id = Request.QueryString["id"];
            var list = _articleRepository.Get().Where(o => id.Contains(o.Id));
            list.ForEach(o => _articleRepository.Delete(o));
            _articleRepository.Save();
            Json(new AjaxResult { state = true, message = "删除成功" });
        }
    }
}